<?php

namespace common\factory;

use EasyWeChat\Factory;
use Yii;


class EasyWeChat
{
    /**
     * 实例化小程序
     * @return \EasyWeChat\MiniProgram\Application
     */
    public static function miniProgram(): \EasyWeChat\MiniProgram\Application
    {
        $config = [
            'app_id' => Yii::$app->params['wxmini.login.appid'],
            'secret' => Yii::$app->params['wxmini.login.secret'],
            // 下面为可选项
            // 指定 API 调用返回结果的类型：array(default)/collection/object/raw/自定义类名
            'response_type' => 'array',
            'log' => [
                'level' => 'debug',
//                'file' => __DIR__.'/wechat.log',
            ],
        ];

        $app = Factory::miniProgram($config);

        return $app;
    }

}